package com.wx.thread;

/**
 * ThreadLocal Test
 * @author wangxun
 * @version 1.0
 * @description: ThreadLocal Test
 * @date 2020/12/31 11:30 上午
 */
public class ThreadLocalTest {
    /**
     * ThreadLocal 中存在 ThreadLocalMap 用于存放不同线程的自己的数据存储
     * 对于同一个线程来说,用table 去存储不同ThreadLocal 对象的数据
     * @param args
     */



    public static void main(String[] args) {
        ThreadLocal threadLocal = new ThreadLocal();
        ThreadLocal threadLocal2 = new ThreadLocal();
        threadLocal.set(2343444);
        threadLocal2.set(222222222);
        System.out.println(Thread.currentThread().getName()+":"+threadLocal.get());
        System.out.println(Thread.currentThread().getName()+":"+threadLocal2.get());


        new Thread(()->{
            System.out.println(Thread.currentThread().getName()+":"+threadLocal.get());
        }).start();
    }
}
